#!/bin/bash

########################################
# Author: Rajiv Ramnath
# Purpose:
# output all the hostnames on the current
# newscorp SAN cert as a list
########################################

edgekey="e416.g.akamaiedge.net:443"

openssl s_client -showcerts -connect $edgekey | openssl x509 -noout -text | grep -i "DNS" > dnstmp.txt

sed 's/ //g' dnstmp.txt | sed 's/DNS://g' | sed -e $'s/,/\\\n/g' | sort > ~/foxsan.txt

echo "Done!. Check foxsan.txt"

rm dnstmp.txt